<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<%@include file="WEB-INF/jspf/browser.jspf" %>
<%
    session.removeAttribute("usuario");
    session.removeAttribute("ID");
    session.removeAttribute("autorizacion");
    session.invalidate();
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Poder Judicial</title>
        <link href="css/login.css" type="text/css" rel="stylesheet">

        <script src="jq/jquery-1.10.2.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            function login(){
                var correo = $("#correo").val();
                var password = $("#password").val();
                
                $.ajax({
                    type: "POST",
                    url: "Usuarios",
                    data: {accion:"LOGIN",correo:correo,password:password},
                    success: function(data) {
                        var result = data.substr(0, 4);
                        
                        if(result === "view") {
                            window.location = data;
                        } else {
                            alert(data);
                        }
                    }
                });
            }
        </script>
    </head>
    <body>
        <form action="Usuarios" method="post">
            <input type="hidden" name="accion" value="LOGIN"/>

            <div class="header"></div>

            <div style="float: left;margin-top: 20px;">
                <img src="images/keys.png" alt="login-icon"/>
            </div>

            <div id="content">
                <table border="0" cellspacing="3" style="margin: auto">
                    <tr>
                        <td style="width: 200px"><label for="correo">Correo </label></td>
                        <td>
                            <input name="correo" id="correo" type="text" value="jramirez"/>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">&nbsp;</td>
                    </tr>
                    <tr>
                        <td><label for="password">Password </label></td>
                        <td>
                            <input type="password" name="password" id="password" value="123456"/>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">&nbsp;</td>
                    </tr>
                </table> 

                <div id="buttons">                   
                    <input name="submit" id="submit" type="button" 
                           onclick="login()" value="Ingresar" />
                </div>
            </div>

            <div class="footer">
                <span style="font-weight: bold">
                    pj.gob.pe
                </span><br/>
                &copy; Todos los derechos reservados
            </div>
        </form>
    </body>
</html>
